Trò chơi Tic-Tac-Toe, game đánh caro full source code
53.581 lượt xem;
- PickupTriggerForward.cs
- Scripts /
- DemoPickup /
- Demos /
- Photon Unity Networking /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 /// <summary>
5 /// Simple script to forward a sub-objects OnTriggerEnter to the parent's PickupItem-component.
6 /// </summary>
7 /// <remarks>
8 /// This is useful when a physcial object has a collider but also needs a trigger.
9 /// </remarks>
10 public class PickupTriggerForward : MonoBehaviour {
11
12
13
14 public void OnTriggerEnter(Collider other)
15 {
16 PickupItem parentPickupItem = this.transform.parent.GetComponent<PickupItem>();
17 if (parentPickupItem != null)
18 {
19 parentPickupItem.OnTriggerEnter(other);
20 }
21
22 // by enabling this log, you can see that more triggers are forwarded than necessary.
23 // collisions with any collider will trigger, which is not perfect but OK in the demo.
24 //Debug.Log("Triggered. Called parent: " + ((parentPickupItem != null)));
25 }
26 }
2 using System.Collections;
3
4 /// <summary>
5 /// Simple script to forward a sub-objects OnTriggerEnter to the parent's PickupItem-component.
6 /// </summary>
7 /// <remarks>
8 /// This is useful when a physcial object has a collider but also needs a trigger.
9 /// </remarks>
10 public class PickupTriggerForward : MonoBehaviour {
11
12
13
14 public void OnTriggerEnter(Collider other)
15 {
16 PickupItem parentPickupItem = this.transform.parent.GetComponent<PickupItem>();
17 if (parentPickupItem != null)
18 {
19 parentPickupItem.OnTriggerEnter(other);
20 }
21
22 // by enabling this log, you can see that more triggers are forwarded than necessary.
23 // collisions with any collider will trigger, which is not perfect but OK in the demo.
24 //Debug.Log("Triggered. Called parent: " + ((parentPickupItem != null)));
25 }
26 }
Simple script to forward a sub-objects OnTriggerEnter to the parent's PickupItem-component.
This is useful when a physcial object has a collider but also needs a trigger.
by enabling this log, you can see that more triggers are forwarded than necessary.
collisions with any collider will trigger, which is not perfect but OK in the demo.
Debug.Log("Triggered. Called parent: " + ((parentPickupItem != null)));